package com.tanhua.server.controller;

import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.vo.PeachblossomVo;
import com.tanhua.server.service.PeachblossomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.text.ParseException;

/**
 * @Description：test
 * @Create by： 张会豪
 * @Date：2021/11/7 9:46
 */
@RestController
@RequestMapping("/peachblossom")
public class PeachblossomController {

    @Autowired
    private PeachblossomService peachblossomService;

    /**
     * 桃花传音-发送语音
     * 请求方式和路径：POST/peachblossom
     * 请求参数：Body|soundFile【文件】
     * 响应数据：无
     */
    @PostMapping
    public ResponseEntity peachblossom(MultipartFile soundFile) throws IOException, ParseException {
        //1、接收参数，调用service执行业务
        UserInfo userInfo = peachblossomService.peachblossom(soundFile);
        //2、响应数据
        return ResponseEntity.ok(null);
    }

    /**
     * 桃花传音-接收语言
     * 请求方式和路径：GET/peachblossom
     * 请求参数：无
     * 响应数据：PeachblossomVo
     */
    @GetMapping
    public ResponseEntity acceptPeachblossom() throws ParseException {
        //1、调用service执行业务
        PeachblossomVo vo = peachblossomService.acceptPeachblossom();
        //2、响应数据
        return ResponseEntity.ok(vo);
    }
}
